package bubble;
import java.util.ArrayList;
import java.util.Collections;
public class bubclass
{

	public static void main(String[] args) 
	{
		int num=5;
		ArrayList<Integer> list= new ArrayList<Integer>(num);
		for (int i=0; i<num; i++)
		{
			list.add(i);
		}
		Collections.shuffle(list);
		System.out.println(list);
		System.out.println(list.get(0));
		int r=0;
		boolean flag=true;
		long start = System.nanoTime();
		for(int i=0; i<(num-1)&&flag; i++)
		{
			
			for (int j=0; j<(num-i-1); j++)
			{
				r=0;
				if (list.get(j)> list.get(j+1))
				{
					int tmp=list.get(j);
					list.set(j, list.get(j+1));
					list.set(j+1,  tmp);
					r++;
				}
				System.out.println(i+","+j+list);
			}
			if (r==0) flag=false;
			
		}
		long end = System.nanoTime();
		long traceTime = end-start;
		System.out.println(traceTime);

	}

}
